﻿@{
    ViewBag.Title = "ParseJsonDemo2";
    Layout = "~/Views/Shared/_Page.cshtml";
}

<h2>Parse Json Demo 2</h2>
<br />
<h3>Employee Info:</h3>
<hr />
<div id="empInfo"></div>

<script type="text/javascript">
    $(document).ready(function () {
        var url = "/Employee/MockEmployees";

        var html = "";
        $.getJSON(url, { format: "json" })
            .done(function (data) {
                listEmployees(data);
            });
    });

    function listEmployees(employees) {
        var html = "";

        for (var i = 0; i < employees.length; i++) {
            html += "<div>Id: " + employees[i].Id + "</div>"
                + "<div>Name: " + employees[i].Name + "</div>"
                + "<div>Title: " + employees[i].Title + "</div>"
                + "<div>Age: " + employees[i].Age + "</div>"
                + "<div>----------------------------------------</div>"
        }
        $("#empInfo").append(html);
    }
</script>
